import os
import sys

def main():
    # 确保Django设置已加载
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'property_management.settings')
    
    import django
    django.setup()
    
    from django.contrib.auth.models import User
    
    try:
        # 获取超级用户
        user = User.objects.get(username='admin')
        # 设置密码为 'admin123456'
        user.set_password('admin123456')
        user.save()
        print("超级用户密码设置成功: admin123456")
    except User.DoesNotExist:
        print("超级用户不存在")
    except Exception as e:
        print(f"设置密码时出错: {e}")

if __name__ == '__main__':
    main()